home *** CD-ROM | disk | FTP | other *** search
/ Apple WWDC 1996 / WWDC96_1996 (CD).toast / Technology Materials / QuickTime VR / MacOS / QuickDraw™ 3D 1.0.6F4 SDK / Samples / SampleCode / Tumbler and Podium / Tumbler_initialize.c < prev    next >
Encoding:
Text File  |  1995-11-13  |  3.2 KB  |  161 lines  |  [TEXT/MPS ]

  1. //        initialize.c
  2. //
  3. //        Initialization routines.
  4. //        
  5. //
  6. //        Author:        Nick Thompson & Pablo Fernicola, with thanks to the QuickDraw 3D team
  7. //        Date:        Tuesday, February 25, 1992
  8. //
  9. //        Copyright © 1992-95 Apple Computer, Inc., All Rights Reserved
  10. //
  11. //    Modification History:
  12. //        11/26/94        nick        added InitializeAppStuff
  13. //
  14.  
  15. #include <Drag.h>
  16. #include <GestaltEqu.h>
  17. #include <segload.h>
  18. #include <GestaltEqu.h>
  19.  
  20.  
  21. #include "Tumbler_globals.h"
  22. #include "Tumbler_resources.h"
  23. #include "Tumbler_utility.h"
  24.  
  25. #include "QD3D.h"
  26.  
  27. #include "Tumbler_initialize.h"
  28.  
  29.  
  30. WindowPtr    pSplasher ;        // used for the splash screen
  31.  
  32. void InitializeToolbox(void)
  33.  
  34. {
  35.     InitGraf(&qd.thePort);
  36.     InitFonts();
  37.     InitWindows();
  38.     InitMenus();
  39.     TEInit();
  40.     InitDialogs(0L);
  41.     InitCursor();
  42.  
  43. }
  44.  
  45. //-----------------------------------------------------------------------
  46. // make sure enough master pointers are allocated or heap fragmentation
  47. // will result!!
  48.  
  49. void InitializeAppStuff( short    numMoreMasters )
  50. {
  51.  
  52.     short            index ;
  53.     long            gestaltResponse;
  54.     
  55.     for( index = 1; index <= numMoreMasters; index++)
  56.         MoreMasters();
  57.         
  58.     MaxApplZone();
  59.  
  60.     FlushEvents(everyEvent, 0);
  61.  
  62.     if ((Gestalt(gestaltDragMgrAttr, &gestaltResponse) != noErr) ||
  63.         (!(gestaltResponse & (1 << gestaltDragMgrPresent)))) {
  64.  
  65.         Alert(512, 0L);
  66.         ExitToShell();
  67.     }
  68. }
  69.  
  70.  
  71. void InitializeGlobals(void)
  72.  
  73. {    Handle            theHandle;
  74.  
  75.     gQuit = gQuitting = false;
  76.     gDocumentCount = 0;
  77.     gFontItem = gSizeItem = 0;
  78.     gInBackground = false;
  79.     gCanUndoDrag = slCantUndo;
  80.     gUsingHardware = false ;
  81.  
  82.     Q3Initialize();
  83. }
  84.  
  85.  
  86. void DeallocateGlobals(void)
  87.  
  88. {
  89.     Q3Exit();    
  90. }
  91.  
  92.  
  93. void SetupMenus(void)
  94.  
  95. {    Handle        theMenuBar;
  96.     MenuHandle    theMenu;
  97.     Str255        theStr;
  98.  
  99.     if ((theMenuBar = GetNewMBar(MenuBarID)) == 0) {
  100.         SysBeep(1);
  101.         ExitToShell();
  102.     }
  103.     SetMenuBar(theMenuBar);
  104. //    DisposHandle(theMenuBar);
  105.  
  106.     AppendResMenu(GetMenuHandle(idAppleMenu), 'DRVR');
  107.     //AppendResMenu(GetMenuHandle(idDisplayMenu), 'FONT');
  108.  
  109.     GetIndString(theStr, MenuStringsID, slCantUndo);
  110.     SetMenuItemText(GetMenuHandle(idEditMenu), iUndo, theStr);
  111.  
  112.     theMenu = GetMenuHandle(idDisplayMenu);
  113.  
  114. #ifndef PODIUM_APP
  115.     InsertMenu(GetMenu(idStyleMenu), -1);
  116.     InsertMenu(GetMenu(idRendererMenu), -1);
  117.     InsertMenu(GetMenu(idAnimateMenu), -1);
  118.     InsertMenu(GetMenu(idBackfacingMenu), -1);
  119. #endif
  120.     DrawMenuBar();
  121. }
  122.  
  123. //-------------------------------------------------------------------------------------------
  124. void    SplashSetUp( void )
  125. {
  126.     PicHandle        thePict = GetPicture( 128 ) ;
  127.     GrafPtr            savedPort ;
  128.     
  129.     GetPort( &savedPort ) ;
  130.     if(thePict != nil) {
  131.     
  132.         GDHandle    theMainDevice = GetMainDevice() ;    // if this is nil then the world just ended
  133.         
  134.         if(theMainDevice != nil) {
  135.             Rect    thePictFrame = (**thePict).picFrame ;
  136.             Rect    deviceRect = (**theMainDevice).gdRect ;
  137.             
  138.             thePictFrame = (**thePict).picFrame ;
  139.             PositionRectInRect(&deviceRect, &thePictFrame, FixRatio(1, 2), FixRatio(1, 3)) ;
  140.             pSplasher = NewWindow(nil,&thePictFrame,"\p",false,dBoxProc,(WindowPtr)-1,false,0L);
  141.             
  142.             if( pSplasher != nil ) {
  143.                 SetWRefCon( pSplasher, (long)savedPort ) ;
  144.                 ShowWindow(pSplasher) ;
  145.                 SetPort((GrafPtr)pSplasher) ;
  146.                 DrawPicture(thePict, &pSplasher->portRect) ;
  147.             }
  148.         }
  149.     }
  150. }
  151.  
  152.  
  153. void    SplashTearDown( void )
  154. {
  155.     GrafPtr savedPort = (GrafPtr)GetWRefCon(pSplasher) ;
  156.     if(pSplasher!=nil) {
  157.         CloseWindow(pSplasher);
  158.         SetPort(savedPort) ;        
  159.     }
  160. }
  161.